<template>
	<view :style="themeColor">
		<view class="page">

			<view class="flex flex-direction flex-wrap align-center justify-center benben-flex-layout ccddLogin_flex_0">
				<image class='ccddLogin_fd0_0' mode="aspectFill" src='/static/images/logo1.png'></image>
			</view>


			<!---登录flex布局开始-->
			<view class="flex flex-direction flex-wrap align-stretch benben-flex-layout ccddLogin_flex_1">
				<view class='flex flex-wrap align-center ccddLogin_fd1_0'>
					<image class='ccddLogin_fd1_0_c0' mode="aspectFit" :src='STATIC_URL+"356.png"'></image>
					<benben-input class='flex-sub ccddLogin_fd1_0_c1' type="number" :placeholder="`请输入手机号`"
						confirm-type="done" :maxlength="11"
						placeholder-style="color:rgba(191, 191, 191, 1);font-size:32rpx" v-model="mobile" />
				</view>
				<view class='flex flex-wrap align-center ccddLogin_fd1_0'>
					<image class='ccddLogin_fd1_0_c0' mode="aspectFit" :src='STATIC_URL+"357.png"'></image>
					<benben-input class='flex-sub' type="number" :placeholder="`请输入验证码`" confirm-type="done"
						:maxlength="4" placeholder-style="color:rgba(191, 191, 191, 1);font-size:32rpx"
						v-model="code" />
					<benben-send-verification-code key='1681875393041' ref="vCode1681875393041"
						class=' ccddLogin_fd1_1_c2' after-text='后重新获取' before-text='获取验证码' type='3'
						:phone="mobile"></benben-send-verification-code>
				</view>
				<text class='self-end ccddLogin_fd1_2' @tap.stop="handleJumpDiy" data-type="redirectTo"
					:data-url="`/pages/tabBar/logon/logon?type=${type}`">密码登录</text>
				<view class='flex flex-wrap align-center justify-center'>
					<button class='ccddLogin_fd1_3_c0' @tap.stop="verificationCodeLoginFunc()">登录</button>
				</view>
				<view class='flex flex-wrap align-center justify-center ccddLogin_fd1_4'>
					<text class='ccddLogin_fd1_4_c0' @tap.stop="handleJumpDiy" data-type="navigateTo"
						:data-url="`/pages/login/registers/registers`">注册账号 </text>
					<view class='flex flex-wrap align-center ccddLogin_fd1_4_c1'>
					</view>
					<text class='ccddLogin_fd1_4_c2' @tap.stop="handleJumpDiy" data-type="navigateTo"
						:data-url="`/pages/login/forgetPassword/forgetPassword?mobile=${mobile}&type=forgot`">忘记密码</text>
				</view>
			</view>

			<!---登录flex布局结束-->
			<view class="flex flex-direction flex-wrap align-stretch benben-position-layout flex ccddLogin_flex_2">
				<view class='flex flex-wrap align-stretch justify-center ccddLogin_fd2_0'>
					<benben-flex-switch-new class-name='flex flex ccddLogin_fd2_0_c0' v-model="select"
						:disabled='false'>
						<template v-slot:checked>

							<view class='flex flex position-relative align-center'>
								<image class='ccddLogin_checkfd2_0_c0_c0_c0' mode="aspectFit"
									:src='STATIC_URL+"169.png"'></image>
							</view>

						</template>
						<template v-slot:unchecked>

							<view class='flex flex position-relative justify-end align-center'>
								<image class='ccddLogin_noCheckfd2_0_c0_c1_c0' mode="aspectFit"
									:src='STATIC_URL+"49.png"'></image>
							</view>

						</template>
					</benben-flex-switch-new>
					<text class='ccddLogin_fd2_0_c1'>已阅读并同意</text>
					<text class='ccddLogin_fd2_0_c2' @tap.stop="handleJumpDiy" data-type="navigateTo"
						:data-url="`/pages/login/agreements/agreements?type=19`">《用户协议》</text>
					<text class='ccddLogin_fd2_0_c1'>与</text>
					<text class='ccddLogin_fd2_0_c2' @tap.stop="handleJumpDiy" data-type="navigateTo"
						:data-url="`/pages/login/agreements/agreements?type=18`">《隐私政策》</text>
				</view>

			</view>
			<view :style="{height: '400rpx'}"></view>
			<benben-popup v-model="popupShow1710747849463" :mask="true" :mask-close-able="false" mode='center'
				:z-index='999'>
				<!---退出登录flex布局开始-->
				<view class="flex flex-direction flex-wrap align-center login_flex_1"
					@tap.stop="popupShow1650940432200=true">
					<text class='login_fd1_0'>该账号已申请注销</text>
					<text class='login_fd1_1'>是否撤销注销？</text>
					<view class='flex flex-wrap align-center login_fd1_2'>
						<button class='login_fd1_2_c0' @tap.stop="popupShow1710747849463=false">否</button>
						<button class='login_fd1_2_c1' @tap.stop="setRevocationFunc()">是</button>
					</view>
				</view>
				<!---退出登录flex布局结束-->
			</benben-popup>

		</view>
	</view>
</template>
<script>
	import {
		validate
	} from '@/common/utils/validate.js'

	export default {
		components: {},


		data() {
			return {
				"popupShow1710747849463": false,
				"mobile": "",
				"code": "",
				"type": "",
				"is_tick": false,
				"codeLoginData": {
					"userinfo": {
						"user_token": "",
						"member_id": "",
						"id": "",
						"account": "",
						"avatar": "",
						"real_name": "",
						"nickname": "",
						"email": "",
						"gender": "",
						"mobile": "",
						"birthday": "",
						"client_id": "",
						"phone": "",
						"user_type": "",
						"shopID": ""
					}
				},
				"select": false
			};
		},
		computed: {
			themeColor() {
				return this.$store.getters.themeColor
			},
			/**
			 * @returns 
			 * Android       安卓
			 * IOS       苹果
			 * Web       H5 或 pc
			 * Wechat       微信小程序
			 * Alipay       支付宝小程序
			 * Baidu       百度小程序
			 * ByteBounce       抖音小程序
			 * 360       360小程序
			 * FastApp       快应用
			 */
			appSystemIdentification() {
				return this.$store.state.appSystemIdentification
			}
		},
		watch: {},
		onLoad(options) {
			let {
				type
			} = options
			if (type !== undefined) this.type = type
		},
		onUnload() {

		},
		onReady() {

		},
		onShow() {

		},
		onHide() {

		},
		onResize() {

		},
		onPullDownRefresh() {

		},
		onReachBottom(e) {

		},
		onPageScroll(e) {

		},
		methods: {
			//验证码登录
			async verificationCodeLoginFunc() {
				if (!validate(this.mobile, 'require')) {
					this.$message.info('手机号不能为空');
					return false;
				}
				if (!validate(this.mobile, 'phone')) {
					this.$message.info('请输入正确的手机号');
					return false;
				}
				if (!validate(this.code, 'require')) {
					this.$message.info('验证码不能为空');
					return false;
				}
				if (!validate(this.code, 'captcha')) {
					this.$message.info('请输入正确的验证码');
					return false;
				}
				if (this.select === false) {
					this.$message.info('请先阅读并同意《用户协议》与《隐私政策》');
					return false;
				}
				//请求方法
				//数据验证

				let datacodeLoginData = await this.$api.dbPost(global.apiUrls.post5c78dca45ebc1, {
					mobile: this.mobile,
					code: this.code,
					user_type: '1'
				});
				if (!datacodeLoginData) return
				if (datacodeLoginData.data.code == -999) {
					this.popupShow1710747849463 = true
					return
				}
				if (datacodeLoginData.data.code != 1) {
					this.$message.info(datacodeLoginData.data.msg);
					return
				}
				let infocodeLoginData = datacodeLoginData.data;
				this.codeLoginData = infocodeLoginData.data

				this.$store.commit('updateUserInfo', this.codeLoginData.userinfo)
				this.$store.commit('saveToken', this.codeLoginData.userinfo.user_token)
				this.getClient()
				if (this.type == 1) {
					this.$urouter.switchTab(`/pages/tabBar/homePage/homePage`);
				} else {
					this.$urouter.navigateBack(1)
				}
			},
			//消息推送
			getClient() {
				/* 获取设备ID用作消息推送 start */
				// #ifdef APP-PLUS
				let client_id = plus.push.getClientInfo().clientid;
				console.log('设备client_id：' + client_id);
				if (client_id) {
					this.$api.post(global.apiUrls.post6655424618774, {
							client_id: client_id,
							client_type: this.appSystemIdentification == 'Android' ? 1 : 2
						})
						.then(result => {
							console.log('设备储存', result);
						});
				}
				// #endif
				/* 获取设备ID end */
			},
			//撤销注销申请
			async setRevocationFunc() {
				//请求方法
				//数据验证

				let data65af32616116b = await this.$api.dbGet(global.apiUrls.post65af32616116b, {
					mobile: this.mobile
				});
				if (!data65af32616116b) return
				if (data65af32616116b.data.code != 1) {
					this.$message.info(data65af32616116b.data.msg);
					return
				}
				this.popupShow1710750049220 = false;
				setTimeout(() => {
					this.verificationCodeLoginFunc()
				}, 1000)
			}
		}
	};
</script>
<style lang="scss" scoped>
	.page {
		width: 100vw;
		overflow-x: hidden;
		min-height: calc(100vh - var(--window-bottom));
		background: #fff;
		background-size: 100% auto;
	}

	.ccddLogin_flex_0 {
		padding: 110rpx 0rpx 80rpx 0rpx;
	}

	.ccddLogin_fd0_0 {
		width: 510rpx;
		height: 150rpx;
	}

	.ccddLogin_flex_1 {
		padding: 0rpx 32rpx 0rpx 32rpx;
	}

	.ccddLogin_fd1_4_c2 {
		font-size: 28rpx;
		font-weight: 400;
		color: #999999;
	}

	.ccddLogin_fd1_4_c1 {
		background: rgba(153, 153, 153, 1);
		width: 1rpx;
		height: 24rpx;
		background-size: 100% auto !important;
		margin: 0rpx 32rpx 0rpx 32rpx;
	}

	.ccddLogin_fd1_4_c0 {
		font-size: 28rpx;
		font-weight: 400;
		color: rgba(153, 153, 153, 1);
	}

	.ccddLogin_fd1_4 {
		line-height: 34rpx;
		margin: 40rpx 0rpx 0rpx 0rpx;
	}

	.ccddLogin_fd1_3_c0 {
		background: #3090FF;
		border-radius: 44rpx 44rpx 44rpx 44rpx;
		font-size: 32rpx;
		color: #fff;
		height: 88rpx;
		line-height: 88rpx;
		font-weight: 500;
		width: 638rpx;
	}

	.ccddLogin_fd1_2 {
		line-height: 40rpx;
		font-size: 28rpx;
		font-weight: 400;
		color: #333333;
		margin: 32rpx 0rpx 48rpx 0rpx;
	}

	.ccddLogin_fd1_1_c2 {
		line-height: 33rpx;
		text-align: center;
		font-size: 28rpx;
		color: rgba(48, 144, 255, 1);
	}

	.ccddLogin_fd1_0_c1 {
		line-height: 45rpx;
		font-size: 32rpx;
		font-weight: 400;
		color: #333;
	}

	.ccddLogin_fd1_0_c0 {
		width: 34rpx;
		height: 34rpx;
		border-radius: 0rpx 0rpx 0rpx 0rpx;
		margin: 0rpx 28rpx 0rpx 0rpx;
	}

	.ccddLogin_fd1_0 {
		border-bottom: 1px solid #eee;
		padding: 40rpx 0rpx 40rpx 0rpx;
	}

	.ccddLogin_flex_2 {
		width: 750rpx;
		height: 400rpx;
		overflow: hidden;
		z-index: 10;
		bottom: calc(0rpx + var(--window-bottom));
	}

	.ccddLogin_fd2_0_c2 {
		color: rgba(64, 158, 250, 1);
		font-size: 22rpx;
		font-weight: 400;
		line-height: 32rpx;
	}

	.ccddLogin_fd2_0_c1 {
		color: rgba(153, 153, 153, 1);
		font-size: 22rpx;
		font-weight: 400;
		line-height: 32rpx;
	}

	.ccddLogin_noCheckfd2_0_c0_c1_c0 {
		border-radius: 16rpx 16rpx 16rpx 16rpx;
		width: 31rpx;
		height: 31rpx;
	}

	.ccddLogin_checkfd2_0_c0_c0_c0 {
		width: 31rpx;
		height: 31rpx;
		border-radius: 16rpx 16rpx 16rpx 16rpx;
	}

	::v-deep .ccddLogin_fd2_0_c0 {
		margin: 0rpx 24rpx 0rpx 0rpx;
	}

	.ccddLogin_fd2_0 {
		margin: auto 0rpx 60rpx 0rpx;
	}

	//弹窗
	.login_flex_1 {
		background: #fff;
		border-radius: 16rpx 16rpx 16rpx 16rpx;
	}

	.login_fd1_0 {
		font-size: 36rpx;
		font-weight: 800;
		line-height: 44rpx;
		color: #333333;
		margin: 40rpx 0rpx 40rpx 0rpx;
	}

	.login_fd1_1 {
		line-height: 44rpx;
		font-size: 32rpx;
		font-weight: 500;
		color: #333333;
	}

	.login_fd1_2_c1 {
		border-top: 1px solid rgba(238, 238, 238, 1);
		border-left: 1px solid rgba(238, 238, 238, 1);
		background: #fff;
		line-height: 110rpx;
		border-radius: 0rpx 0rpx 16rpx 0rpx;
		font-size: 32rpx;
		color: var(--benbenFontColor4);
		width: 264rpx;
	}

	.login_fd1_2_c0 {
		border-top: 1px solid #eee;
		background: #fff;
		line-height: 110rpx;
		border-radius: 0rpx 0rpx 0rpx 16rpx;
		font-size: 32rpx;
		color: rgba(153, 153, 153, 1);
		padding: 0rpx 103rpx 0rpx 103rpx;
	}

	.login_fd1_2 {
		margin: 37rpx 0rpx 0rpx 0rpx;
	}
</style>